package model;

import java.util.Collection;
import java.util.HashSet;

public class ArcSet {

	private final HashSet<PlaceTransitionArc> placeTransitionArcs;
	private final HashSet<TransitionPlaceArc> transitionPlacearcs;
	
	/**
	 * Constructor of {@link ArcSet}.
	 */
	public ArcSet() {
		this.placeTransitionArcs = new HashSet<PlaceTransitionArc>();
		this.transitionPlacearcs = new HashSet<TransitionPlaceArc>();
	}

	/**
	 * Adds an {@link Arc} to this {@link ArcSet}.
	 * If the provided {@link Arc} is already in this {@link ArcSet} nothing is done.
	 * @param arc is the added {@link Arc}.
	 */
	public void add(final Arc arc) {
		arc.accept(new ArcVisitor() {
			
			@Override
			public void visit(final TransitionPlaceArc transitionPlaceArc) {
				transitionPlacearcs.add(transitionPlaceArc);
			}
			
			@Override
			public void visit(final PlaceTransitionArc placeTransitionArc) {
				placeTransitionArcs.add(placeTransitionArc);
			}
		});
	}

	/**
	 * Provides the {@link Arc}s in this {@link ArcSet} going from a {@link Place} to a {@link Transition}.
	 * @return {@link Arc}s going from a {@link Place} to a {@link Transition}.
	 */
	public Collection<PlaceTransitionArc> getPlaceTransitionArcs() {
		return this.placeTransitionArcs;
	}
	
	/**
	 * Provides the {@link Arc}s in this {@link ArcSet} going from a {@link Transition} to a {@link Place}.
	 * @return {@link Arc}s going from a {@link Transition} to a {@link Place}.
	 */
	
	public Collection<TransitionPlaceArc> getTransitionPlaceArcs(){
		return this.transitionPlacearcs;
	}

}